/*
 *  Arrow
 *
 *  Created by David Giovannini on 1/5/07.
 *  Copyright 2007 Software by Jove. All rights reserved.
 *
 */
 
namespace SBJ
{

namespace Arrow
{

inline bool
Channel::isDispatching( void ) const
{
	return ( m_useDispatcher == true );
}

inline Queue::Stats
Channel::getQueueStats( void ) const
{
	return m_queue->getStats();
}

inline MessageHolder::Stats
Channel::getMessageHolderStats( void ) const
{
	if ( m_msgHolder )
		return m_msgHolder->getStats();
	return MessageHolder::Stats();
}

template < typename MsgType > Publication&
Channel::publish( const std::string& pubKey )
{
	return m_pubMgr.publish< MsgType >( pubKey );
}

template < typename MsgType, typename Allocator > Publication&
Channel::publishWithAlloc( const Allocator& allocator, const std::string& pubKey )
{
	return m_pubMgr.publishWithAlloc< MsgType >( allocator, pubKey );
}

template < typename MsgType > Topic
Channel::getTopic( const std::string& topicKey ) const
{
	return m_pubMgr.getTopic< MsgType >( topicKey );
}

template < typename MsgType, typename Subscriber > Subscription
Channel::makeTypedSubscription( Subscriber* subscriber, const std::string& topicKey, const std::string& filter )
{
	typename MsgType::Subscriber* safeSubscriber = subscriber;
	return Subscription( *this, safeSubscriber, m_pubMgr.makeTopic< MsgType >( topicKey ), filter );
}

template < typename MsgType, typename Subscriber > Subscription
Channel::makeSubscription( Subscriber* subscriber, const std::string& pubKey, const std::string& topicKey, const std::string& filter )
{
	typename MsgType::Subscriber* safeSubscriber = subscriber;
	return Subscription( *this, safeSubscriber, m_pubMgr.makeTopic< MsgType >( topicKey ), filter );
}

}

}
